package com.cinema.model;

import java.time.LocalDateTime;

public abstract class User {
    protected String userId;
    protected String username;
    protected String password;
    protected LocalDateTime registerTime;
    protected String userType;
    protected String phoneNumber;

    // 构造函数
    public User(String userId, String username, String password,
                String userType, String phoneNumber) {
        this.userId = userId;
        this.username = username;
        this.password = password;
        this.registerTime = LocalDateTime.now();
        this.userType = userType;
        this.phoneNumber = phoneNumber;
    }

    // Getter方法
    public String getUserId() {
        return userId;
    }

    public String getUsername() {
        return username;
    }

    public String getPassword() {
        return password;
    }

    public LocalDateTime getRegisterTime() {
        return registerTime;
    }

    public String getUserType() {
        return userType;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    // Setter方法
    public void setPassword(String password) {
        this.password = password;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    // 抽象方法 - 修改密码
    public abstract boolean changePassword(String oldPassword, String newPassword);

    // toString方法用于调试
    @Override
    public String toString() {
        return "User{" +
                "userId='" + userId + '\'' +
                ", username='" + username + '\'' +
                ", userType='" + userType + '\'' +
                ", registerTime=" + registerTime +
                ", phoneNumber='" + phoneNumber + '\'' +
                '}';
    }
}
